GBML manual / 3D

view3d_line_clear

True when no wall, and no door that is not open, is between the two places: a line of sight. Use it to decide whether an enemy can see you.

Game Boy: not available

Game Boy Color: not available

On other consoles this differs: see Side by side and How the consoles differ.

Syntax

view3d_line_clear(x1, y1, x2, y2) -> bool

Arguments

NameType
x1real
y1real
x2real
y2real

Returns

bool

Description

True when no wall, and no door that is not open, stands between the two room places (room pixels counted from the room's top-left corner): a line of sight. Use it to decide whether an enemy can see you before it fires, or whether a thing can be picked up through a window.

It walks the map tile by tile like a ray, so a long line costs about as much as drawing one screen column. A door counts as open once it is open enough to walk through. Things do not block it.

Example

// does the enemy see the camera?
if (view3d_line_clear(x, y, view3d_x(), view3d_y())) {
    x += 0.5;
}

The enemy only advances while it can see the camera.

On the GBA

It walks the map tile by tile like a ray, so a long line costs about as much as drawing one screen column. A door counts as open once it is open enough for the camera to walk through. Things do not block it.

See also: Enemies and items in 3Dview3d_shootview3d_ray